package Entities;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;

/**
 *
 * @author Sincerelypwnd
 */
public class Enemy extends Entity {

    float damage;
    float walkSpeed;
    float rotation;
    float attackSpeed;
    float health;
    public boolean alive = true;

    public Enemy(float x, float y, String imgLocation, float damage, float walkSpeed, float rotation, float attackspeed, float health) throws SlickException {
        super(x, y, imgLocation);

        this.damage = damage;
        this.walkSpeed = walkSpeed;
        this.rotation = rotation;
        this.attackSpeed = attackspeed;
        this.health = health;

    }

    /**
     * Adds damage to health
     * @param damageToDo the damage to apply to the enemy
     * 
     * 
     */
    public void DamageDone(float damageToDo) {
        health -= damageToDo;
        if (health <= 0) {
            alive = false;
        }
    }

    public void move() {
        x = (float) (x - (walkSpeed * .04));
    }

    public void update() {
        move(); 
        //withinAttackRange();

    }
    
    @Override
    public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException{
        g.drawImage(image, x, y);
        //g.drawString(String.valueOf(health), x, y);
    }
    
    public boolean isOffScreen() {
        if (x < -50) {
            return true;
        } else {
            return false;
        }
    }
}